package ex1.game.players;

import ex1.game.Action;
import ex1.game.Player;
import ex1.game.PrisonersDilemmaGame;

public class GrimPlayer implements Player {

	private boolean _hasOtherPlayerDefected = false;
	
	@Override
	public Action playGame(PrisonersDilemmaGame game,
			Action otherPlayerLastAction) {
		
		if (otherPlayerLastAction == null)
		{
			_hasOtherPlayerDefected = false;
		}
		
		if (otherPlayerLastAction == Action.Deffect)
		{
			_hasOtherPlayerDefected = true;
		}
		
		if (_hasOtherPlayerDefected)
		{
			return Action.Deffect;
		}
		return Action.Cooperate;
	}
	
	@Override
	public String toString()
	{
		return "GrimPlayer";
	}

}
